package com.swordxu.yim.android.imlib.network.packet.base;

/**
 * Created by 徐晓明 on 2015/1/8.
 */
public abstract class Packet {
    protected Request mRequest;

    protected Response mResponse;

    public Request getmRequest() {
        return mRequest;
    }

    public void setmRequest(Request mRequest) {
        this.mRequest = mRequest;
    }

    public Response getmResponse() {
        return mResponse;
    }

    public void setmResponse(Response mResponse) {
        this.mResponse = mResponse;
    }

    public abstract String encode();
    public abstract void decode(String buffer);

    /**
     * 请求包的数据结构基类，子类可以继承后添加属于自己的字段
     */
    public static class Request {
        /*** 成员变量 ***/
        protected Header mHeader;

        public Header getHeader() {
            return mHeader;
        }

        public void setHeader(Header header) {
            mHeader = header;
        }
    }

    /**
     * 应答包的数据结构基类，子类可以继承后添加属于自己的字段
     */
    public static class Response {
        /*** 成员变量 ***/
        protected Header mHeader;

        public Header getHeader() {
            return mHeader;
        }

        public void setHeader(Header header) {
            mHeader = header;
        }
    }

    protected boolean mNeedMonitor;

    public void setNeedMonitor(boolean bNeedMonitor) {
        mNeedMonitor = bNeedMonitor;
    }

    public int getSequenceNo() {
        return (int) (mRequest.mHeader.getReserved());
    }

    public boolean getNeedMonitor() {
        return mNeedMonitor;
    }

}
